<?php

class Ead_Form_Compra extends Zend_Form
{

    public function init() {
   	    
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        
        $this->setName('form_'.$controller);

        $el = new Zend_Form_Element_Hidden('COM_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))
            ->addFilter('Int');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Text('COM_DATHOR');
        $el->setLabel('Data/Hora')
        ->setAttrib('readonly',true);
        $el->setAttrib('class', 'datahora');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('CUR_NOM');
        $el->setLabel('Curso')
        ->setAttrib('readonly',true);
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('USU_NOME');
        $el->setLabel('Comprador')
        ->setAttrib('readonly',true);
        $this->addElement($el);
        
        
        $formas = compras::formasPagamento();
        
        $el = new Zend_Form_Element_Select('COM_TPOPAG',array('onchange' => ''));
        $el->setLabel('Formas de Pagamento')
        ->setAttrib('disabled',true)
        ->addMultiOptions($formas);
        $el->setAttrib('class', 'tam_med');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('COM_VES');
        $el->setLabel('Vezes')
        ->setAttrib('class', 'numero')
        ->setAttrib('readonly',true);
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('COM_DES');
        $el->setLabel('Desconto')
        ->setAttrib('class', 'numero')
        ->setAttrib('readonly',true);
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Text('COM_VLR');
        $el->setLabel('Valor')
        ->setAttrib('readonly',true);
        $el->setAttrib('class', 'valor');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('COM_DATPAG');
        $el->setLabel('Data de Pagamento')
                ->addValidator('NotEmpty');
        $el->setAttrib('class', 'data');
        $this->addElement($el);
        
        $status = compras::returnStatus();
             
        $el = new Zend_Form_Element_Select('COM_STATRA',array('onchange' => ''));
        $el->setLabel('Status')
        ->addMultiOptions($status);
        $el->setAttrib('class', 'tam_med');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('submit',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setLabel('Gravar');
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-button btn-ok');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        //$btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-button btn-cancel">Cancelar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-button btn-cancel');
        $this->addElement($btn);
        
        
    }

}

